﻿using System;
using System.Collections.Generic;
using System.Text;
using Tao.Sdl;

namespace Ommf
{
    public class KeyboardManager
    {
        private OmmfEngine engine;
        private byte[] keyState = new byte[400];

        internal KeyboardManager(OmmfEngine engine)
        {
            this.engine = engine;
        }

        internal void Update()
        {
            int temp;
            keyState = Sdl.SDL_GetKeyState(out temp);
        }

        public bool IsDown(Key key)
        {
            return keyState[(int)key] != 0;
        }

        public event EventHandler<KeyEventArgs> KeyPressed;
        internal void OnKeyPressed(Key key)
        {
            if (KeyPressed != null) KeyPressed(this, new KeyEventArgs(key));
        }

        public event EventHandler<KeyEventArgs> KeyReleased;
        internal void OnKeyReleased(Key key)
        {
            if (KeyReleased != null) KeyReleased(this, new KeyEventArgs(key));
        }
    }
}
